package com.potenza.training.resume.controller;

import com.potenza.training.dictionary.entity.Industry;
import com.potenza.training.dictionary.entity.PositionOne;
import com.potenza.training.resume.entity.WorkExperienceEntity;
import com.potenza.training.resume.feign.DictionartFeig;
import com.potenza.training.resume.service.WorkExperienceService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 工作经历
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-07-15 17:19:05
 */
@RestController
@RequestMapping("resume/workexperience")
public class WorkExperienceController {
    @Autowired
    private WorkExperienceService workExperienceService;
    @Autowired
    DictionartFeig dictionartFeig;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("resume:workexperience:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = workExperienceService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 通过用户登录ID获取数据
     */
    @RequestMapping("/list/{resumeId}")
    @RequiresPermissions("resume:workexperience:list")
    public List<WorkExperienceEntity> list(@PathVariable Integer resumeId){
        return workExperienceService.findByUid(resumeId);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("resume:workexperience:info")
    public R info(@PathVariable("id") Long id){
		WorkExperienceEntity workExperience = workExperienceService.getById(id);

        return R.ok().put("workExperience", workExperience);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("resume:workexperience:save")
    public R save(@RequestBody WorkExperienceEntity workExperience){
		workExperienceService.save(workExperience);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("resume:workexperience:update")
    public R update(@RequestBody WorkExperienceEntity workExperience){
		workExperienceService.updateById(workExperience);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("resume:workexperience:delete")
    public R delete(@RequestBody Long[] ids){
		workExperienceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    //查询行业表

    @RequestMapping("/findindustry")
    public List<Industry> findindustry(){

        return  dictionartFeig.findindustry();
    }

    //职业分类
    @RequestMapping("/findpostion")
    public  List<PositionOne> findpostion(){
        return  dictionartFeig.edit();
    }

}
